package com.example.hj.controller;


import com.example.hj.entity.Student;
import com.example.hj.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huangjian
 * @since 2019-05-30
 */
@Controller
@RequestMapping("/school/student")
public class StudentController {

    @Autowired
    private IStudentService studentService;

    @RequestMapping(value = "/list")
    public String list(Model model) {
        System.out.println("list---------- ++++++= " );
        List<Student> list = studentService.getStudentList();
        for (Student student:list) {
            System.out.println(student.getName()+"--------"+student.getId());
        }
        model.addAttribute("students", list);
        return "/school/student/list";
    }

    @RequestMapping(value = "/tt")
//    @ResponseBody
    public String tt(Model model) {
        System.out.println("---------- ++++++= ");
        List<Student> list = studentService.selectStudentByClass();
        for (Student student : list) {
            System.out.println(student.getName() + "--------" + student.getId());
        }
        model.addAttribute("content", "hello");
        model.addAttribute("students", list);
        return "/tt";
    }

}
